﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Works.aspx.cs" Inherits="_Default" MasterPageFile="~/Admin/Administrator.master" Title = "Works Page"%>

<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" >
    <p>
        <dx:ASPxGridView ID="gvwWorks" runat="server" AutoGenerateColumns="False" 
            Caption="Details of Work" CssFilePath="~/App_Themes/DevEx/{0}/styles.css" 
            CssPostfix="DevEx" DataSourceID="dataMain" KeyFieldName="WorkID" 
            onrowvalidating="gvwWorks_RowValidating" Width="100%">
            <Columns>
                <dx:GridViewCommandColumn VisibleIndex="0">
                    <EditButton Visible="True">
                    </EditButton>
                    <NewButton Visible="True">
                    </NewButton>
                    <DeleteButton Visible="True">
                    </DeleteButton>
                    <UpdateButton Text="Save">
                    </UpdateButton>
                    <ClearFilterButton Visible="True">
                    </ClearFilterButton>
                </dx:GridViewCommandColumn>
                <dx:GridViewDataComboBoxColumn Caption="Staff" FieldName="StaffID" 
                    VisibleIndex="1">
                    <PropertiesComboBox DataSourceID="dataStaff" 
                        IncrementalFilteringMode="Contains" TextField="StaffID" ValueField="StaffID">
                        <Columns>
                            <dx:ListBoxColumn FieldName="StaffID" />
                            <dx:ListBoxColumn FieldName="Firstname" Name="Fisrt Name" />
                            <dx:ListBoxColumn FieldName="Lastname" Name="Last Name" />
                        </Columns>
                    </PropertiesComboBox>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataComboBoxColumn Caption="Class" FieldName="ClassID" 
                    VisibleIndex="2">
                    <PropertiesComboBox DataSourceID="dataClass" TextField="ClassID" 
                        ValueField="ClassID">
                    </PropertiesComboBox>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataComboBoxColumn Caption="Course" FieldName="CourseID" 
                    VisibleIndex="3">
                    <PropertiesComboBox DataSourceID="dataCousre" TextField="Course_Name" 
                        ValueField="CourseID">
                    </PropertiesComboBox>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataDateColumn Caption="Work Date" FieldName="Work_Date" 
                    VisibleIndex="4">
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataComboBoxColumn FieldName="Remark" VisibleIndex="5">
                    <PropertiesComboBox>
                        <Items>
                            <dx:ListEditItem Text="Best" Value="Best" />
                            <dx:ListEditItem Text="Better" Value="Better" />
                            <dx:ListEditItem Text="Good" Value="Good" />
                            <dx:ListEditItem Text="Moderate" Value="Moderate" />
                            <dx:ListEditItem Text="Normal" Value="Normal" />
                        </Items>
                    </PropertiesComboBox>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataTextColumn FieldName="WorkID" ReadOnly="True" Visible="False" 
                    VisibleIndex="6">
                    <EditFormSettings Visible="True" />
                </dx:GridViewDataTextColumn>
            </Columns>
            <Settings ShowFilterRow="True" />
            <Images SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css">
                <LoadingPanelOnStatusBar Url="~/App_Themes/DevEx/GridView/StatusBarLoading.gif">
                </LoadingPanelOnStatusBar>
                <LoadingPanel Url="~/App_Themes/DevEx/GridView/Loading.gif">
                </LoadingPanel>
            </Images>
            <ImagesFilterControl>
                <LoadingPanel Url="~/App_Themes/DevEx/GridView/Loading.gif">
                </LoadingPanel>
            </ImagesFilterControl>
            <Styles CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx">
                <Header ImageSpacing="5px" SortingImageSpacing="5px">
                </Header>
                <LoadingPanel ImageSpacing="5px">
                </LoadingPanel>
            </Styles>
            <StylesEditors ButtonEditCellSpacing="0">
                <ProgressBar Height="21px">
                </ProgressBar>
            </StylesEditors>
        </dx:ASPxGridView>
        <asp:SqlDataSource ID="dataMain" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Institte_of_Fine_ArtsConnectionString %>" 
            InsertCommand="INSERT INTO Work_Details(StaffID, ClassID, CourseID, Work_Date, Remark) VALUES (@StaffID, @ClassID, @CourseID, @Work_Date, @Remark)" 
            SelectCommand="SELECT * FROM [Work_Details]" 
            UpdateCommand="UPDATE Work_Details SET StaffID = @StaffID, ClassID = @ClassID, CourseID = @CourseID, Work_Date = @Work_Date, Remark = @Remark WHERE (WorkID = @WorkID)">
            <InsertParameters>
                <asp:Parameter Name="StaffID" />
                <asp:Parameter Name="ClassID" />
                <asp:Parameter Name="CourseID" />
                <asp:Parameter Name="Work_Date" />
                <asp:Parameter Name="Remark" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="StaffID" />
                <asp:Parameter Name="ClassID" />
                <asp:Parameter Name="CourseID" />
                <asp:Parameter Name="Work_Date" />
                <asp:Parameter Name="Remark" />
                <asp:Parameter Name="WorkID" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="dataCousre" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Institte_of_Fine_ArtsConnectionString %>" 
            SelectCommand="SELECT * FROM [Course]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="dataClass" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Institte_of_Fine_ArtsConnectionString %>" 
            SelectCommand="SELECT * FROM [Class]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="dataStaff" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Institte_of_Fine_ArtsConnectionString %>" 
            SelectCommand="SELECT [StaffID], [Firstname], [Lastname] FROM [Staff]">
        </asp:SqlDataSource>
    </p>
</asp:Content>